local sk__jiwu = fk.CreateSkill {

  name = "sk__jiwu",

  tags = {  },

}



sk__jiwu:addEffect("active", {
  name = "sk__jiwu",
  anim_type = "offensive",
  card_num = function ()
    if Self:isKongcheng() then
      return 0
    else
      return Self:getHandcardNum() - 1
    end
  end,
  target_num = 0,
  prompt = "#sk__jiwu",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__jiwu.name, Player.HistoryPhase) == 0 and player:getHandcardNum() ~= 1
  end,
  card_filter = function(self, player, to_select, selected)
    if player:isKongcheng() then
      return false
    else
      return #selected < (player:getHandcardNum() - 1) and not player:prohibitDiscard(to_select) and
        Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
    end
  end,
  feasible = function (self, selected, selected_cards,player)
    if player:isKongcheng() then
      return #selected_cards == 0
    else
      return #selected_cards == (player:getHandcardNum() - 1)
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    if #effect.cards > 0 then
      room:throwCard(effect.cards, sk__jiwu.name, player, player)
    else
      player:drawCards(1, sk__jiwu.name)
    end
  end,
})

sk__jiwu:addEffect(fk.CardUsing, {
  name = "#sk__jiwu_delay",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:usedSkillTimes("sk__jiwu", Player.HistoryTurn) > 0 and data.card.trueName == "slash"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("sk__jiwu")
    player.room:notifySkillInvoked(player, "sk__jiwu", "offensive")
    data.additionalDamage = (data.additionalDamage or 0) + 1
  end,
})

sk__jiwu:addEffect("targetmod", {
  name = "#sk__jiwu_targetmod",
  --sk__jiwu,
  bypass_distances =  function(self, player, skill)
    return skill.trueName == "slash_skill" and player:usedSkillTimes("sk__jiwu", Player.HistoryTurn) > 0
  end,
  extra_target_func = function(self, player, skill)
    if skill.trueName == "slash_skill" and player:hasSkill(sk__jiwu.name) and #player:getCardIds("e") == 0 then
      return 2
    end
  end,
})

return sk__jiwu